package com.example.springbootvuecalender.controller;

import com.example.springbootvuecalender.dao.CalenderDao;
import com.example.springbootvuecalender.entity.Calender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/calender")
public class CalenderController {

    @Autowired
    CalenderDao calenderDao;

    @GetMapping
    public List<Calender> list() {
        return calenderDao.findAll();
    }

    @PostMapping
    public void add(@RequestBody Calender calender) {
        calenderDao.save(calender);
    }

    @GetMapping("/date")
    public Calender date(@RequestParam String date){
       return calenderDao.findAllByDate(date);
    }
}
